<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;

class Controller extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
    public function delToken(array $params){
        if (empty($params)){
            return [];
        }
        if (isset($params['_token'])){
            unset($params['_token']);
        }
        return $params;
    }

    public function uploadFile($files){
//        dd($files);die;
        if (empty($files)){
            return '/images/3.jpeg';
        }
        $basePath='uploads/'.date('Y-m-d',time());
//        dd($files);
        if (!file_exists($basePath)){
            mkdir($basePath,755,true);
        }
        $filename="/".date('YmdHis',time()).".".$files->extension();


        move_uploaded_file($files->path(),$basePath.$filename);
//dd("/".$basePath.$filename);
        return "/".$basePath.$filename;
    }

}
